'use strict'

const dayjs = require('dayjs')

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
  const { router, controller, middleware } = app
  const { wechatNotify } = middleware
  const { jwtAuth } = middleware.auth
  const { config } = app
  const { client } = controller

  const prefix = `/`

  /**
   *测试
   */
  router.get(`/test/:action`, client.test.test)

  /**
   * 微信公众号
   */
  const wechatAuth = middleware.wechatAuth(config.wechat.auth)

  router.get('/wechat/mp/oauth2', client.wechatMp.oauth2Callback) // 授权回调
  router.get('/wechat/mp/auth', wechatAuth, client.wechatMp.auth) // 主动授权页面
  router.get('/wechat/mp/login', wechatAuth, client.wechatMp.login) // 微信公众登录
  router.get('/wechat/mp/js-sdk', client.wechatMp.jsSdk) // 微信JS-SDK
  router.get('/wechat/mp/user-info', client.wechatMp.userInfo) // 公众号用户信息
}
